package eerbaar.shared.tree;

import java.util.List;

import eerbaar.shared.internal.tree.commands.AddCmd;
import eerbaar.shared.internal.tree.commands.FindChildCmd;
import eerbaar.shared.internal.tree.commands.FindChildrenCmd;
import eerbaar.shared.internal.tree.commands.FindValueCmd;
import eerbaar.shared.internal.tree.commands.MergeChildrenCmd;
import eerbaar.shared.internal.tree.commands.RemoveAllChildrenCmd;
import eerbaar.shared.internal.tree.commands.RemoveCmd;


public final class NodeCmdFactory {

    public static void add(INode parent, INode child) {
        new AddCmd(parent).execute(child);
    }

    public static INode findChild(INode start, String name) {
        return new FindChildCmd(start).execute(name);
    }

    public static List<INode> findChildren(INode start, String name) {
        return new FindChildrenCmd(start).execute(name);
    }

    public static INode findValue(INode start, String name) {
        return new FindValueCmd(start).execute(name);
    }

    public static void mergeChildren(INode parent) {
        new MergeChildrenCmd().execute(parent);
    }

    public static void remove(INode parent, INode child) {
        new RemoveCmd(parent).execute(child);
    }

    public static void remove(INode parent, List<INode> children) {
        new RemoveCmd(parent).execute(children);
    }

    public static void removeAllChildren(INode start) {
        new RemoveAllChildrenCmd().execute(start);
    }

    private NodeCmdFactory() {
        //
    }

}
